<body>
<div class="layui-fluid">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-header">{$page_name}</div>
				<div class="layui-card-body" pad15>
<form action="{:url(request()->action())}" method="post">
					<div class="layui-form">
						<div class="layui-form-item">
							<label class="layui-form-label">友链组</label>
							<div class="layui-input-inline">
								<select name="cat_id" lay-filter="cat_id">
								{volist name="poster_lists" id="vo"}
									<option value="{$vo.id}" {if $vo.id == $info.cat_id} selected {/if} data-content="{$vo.info}">{$vo.name}</option>
								{/volist}
								</select> 
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">友链名称</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="title" value="{$info.title}" lay-verify="required" placeholder="请输入友链名称">
							</div>
							<div class="layui-form-mid layui-word-aux">请输入友链名称</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">跳转地址</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="url" value="{$info.url}" lay-verify="required" placeholder="请输入跳转地址">
							</div>
							<div class="layui-form-mid layui-word-aux">请输入跳转地址，1.本站相对地址以“/”开始；2绝对地址以https、http开始；3.留空。</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">友链图片</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input img_input" name="img" value="{$info.img}" lay-verify="required" placeholder="请上传友链图片">
							</div>
							<div class="layui-input-inline" style="width: auto;">
								<button type="button" class="layui-btn layui-btn-primary wy-upload" 
									id="img_button"
									style="margin-bottom:0;"
									wy-data="{
										accept:'images',
										acceptMime:'image/*',
										exts: 'jpg|png|gif|bmp|jpeg',
										data:{savepath:'links'},
										img_url:'.img_img',
										input_url:'.img_input'
									}">
									<i class="layui-icon layui-icon-upload"></i>上传图片
								</button>
							</div>
							
							<div class="layui-input-inline" style="width: auto;">
								<button type="button" class="layui-btn layui-btn-primary wy-work" 
									id="img_work"
									style="margin-bottom:0;"
									wy-data="{
										path:'links',
										exts: 'jpg|png|gif|bmp|jpeg',
										img_url:'.img_img',
										input_url:'.img_input'
									}">
									<i class="layui-icon layui-icon-file"></i>文件空间
								</button>
							</div>
							
							<div class="layui-form-mid layui-word-aux" id="show_cat_info"></div>
						</div>
				
						<div class="layui-form-item" id="img_show">
							<label class="layui-form-label"></label>
							<div class="layui-input-block" id="img_show_div">
								<img src="{$info.img|default=config('app.noimg')}" class="img_img wy-uploads_img">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">展示顺序</label>
							<div class="layui-input-inline">
								<input type="number" class="layui-input" name="sort" value="{$info.sort}" min="0" lay-verify="" placeholder="">
							</div>
							<div class="layui-form-mid layui-word-aux">展示顺序，数值越大越靠前</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">展示时间</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input wy-datetime" name="start_time" value="{$info.start_date}" placeholder="开始时间">
							</div>
							<div class="layui-form-mid">-</div>
							<div class="layui-input-inline">
								<input type="text" class="layui-input wy-datetime" name="end_time" value="{$info.end_date}" placeholder="结束时间">
							</div>
							<div class="layui-form-mid layui-word-aux">为空表示不显示展示时间</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">启用状态</label>
							<div class="layui-input-block">
								<input type="radio" name="status" value="1" title="开启" {if $info.status == 1} checked {/if}>
								<input type="radio" name="status" value="0" title="关闭" {if $info.status == 0} checked {/if}>
							</div>
						</div>
						<div class="layui-form-item layui-form-text">
							<label class="layui-form-label">友链备注</label>
							<div class="layui-input-block" style="max-width: 400px;">
								<textarea name="info" class="layui-textarea" placeholder="请输入备注内容">{$info.info}</textarea>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<input name="id" type="hidden" value="{$info.id}">
								<button class="layui-btn" 
									lay-submit 
									lay-filter="wy-submit"
									wy-changetabid="linksimages_index"
									wy-closetabid="linksimages_info"
									wy-reloadtable="wy_table_lists"
								>确认提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
							</div>
						</div>
					</div>
</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
layui.use(['form'], function(){
	var $ = layui.jquery,form = layui.form;
	show_cat_info(0);
	form.on('select(cat_id)',function(data){
		show_cat_info(data.value);
	});
	function show_cat_info(value){
		var info = '';
		if(value == 0){
			info = $("select[lay-filter='cat_id']").find("option:selected").attr("data-content");
		}else{
			info = $("select[lay-filter='cat_id']").find("option[value='"+value+"']").attr("data-content");
		}
		info += "；只允许上传 jpg|png|gif|bmp|jpeg 格式的图片地址";
		$("#show_cat_info").html(info);
	}
});

</script>
</body>